; *** Chess, Fairy
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com

(version "2.0")
(translate 
 ("Fairy Chess" "仙灵棋简介（看介绍）")
 ("Shatranj" "国际象棋的祖先——沙特兰兹")
 ("Maharaja and the Sepoys" "亚马逊单挑战")
 ("Berolina Chess" "拜罗琳娜兵")
 ("No High Ground" "禁入中心")
 ("Grasshopper Chess" "跳跃者")
 ("Emperor King Chess" "自在天王")
 ("Stationary King Chess" "王不动")
 ("Grand Chess" "10x10大型象棋")
)

(define available    (verify (and not-friend? (not-piece? Block))) )
(define capturable   (verify (and enemy? (not-piece? Block))) )

(define leap1        ($1          (available) add) )
(define leap2        ($1 $2       (available) add) )
(define leap3        ($1 $2 $3    (available) add) )
(define leap4        ($1 $2 $3 $4 (available) add) )

(define leap1ride    ($1       (while empty? add $1      ) (available) add) )
(define leap2ride    ($1 $2    (while empty? add $1 $2   ) (available) add) )
(define leap3ride    ($1 $2 $3 (while empty? add $1 $2 $3) (available) add) )

(define shift2       ($1 (verify empty?) $2 (available) add) )

(define grasshop     ($1 (while empty? $1) $1 (verify not-friend?) add) )
(define Locust-move  ($1 (while empty? $1) (capturable) capture $1 (verify empty?) add) )
(define Lion-move    ($1 (while empty? $1) $1 (while empty? add $1) (available) add) )

(define King-shift   ($1 (available) (set-attribute never-moved? false) add) )

(define Rook-ride (
  $1
  (while empty? (set-attribute never-moved? false) add $1)
  (available)
  (set-attribute never-moved? false)
  add
))

(define Bishop-moves
     (leap1ride ne)
     (leap1ride nw)
     (leap1ride se)
     (leap1ride sw)
)
(define Rook-moves
     (leap1ride n)
     (leap1ride s)
     (leap1ride e)
     (leap1ride w)
)
(define Knight-moves
	 (leap2 n ne)
	 (leap2 n nw)
	 (leap2 s se)
	 (leap2 s sw)
	 (leap2 e ne)
	 (leap2 e se)
	 (leap2 w nw)
	 (leap2 w sw)
)
(define Camel-moves
	 (leap3 n n ne)
	 (leap3 n n nw)
	 (leap3 s s se)
	 (leap3 s s sw)
	 (leap3 e e ne)
	 (leap3 e e se)
	 (leap3 w w nw)
	 (leap3 w w sw)
)
(define Fers-moves
     (leap1 nw)
     (leap1 ne)
     (leap1 sw)
     (leap1 se)
)
(define Wazir-moves
     (leap1 n)
     (leap1 e)
     (leap1 s)
     (leap1 w)
)
(define Dabbaba-moves
     (leap2 n n)
     (leap2 e e)
     (leap2 w w)
     (leap2 s s)
)
(define Alfil-moves
     (leap2 nw nw)
     (leap2 ne ne)
     (leap2 sw sw)
     (leap2 se se)
)

(define O-O
	 ( (verify never-moved?)
	   mark
	   e ; KB1
	   (verify empty?)
	   e ; KN1
	   (verify empty?)
	   cascade
	   e ; KR1
	   (verify (and friend? (piece? Rook) never-moved?) )
	   from
	   back ; K1
		 ; Save expensive not-attacked?s for last
	   (verify not-attacked?)
	   e ; KB1
	   (verify not-attacked?)
	   to
	   (set-attribute never-moved? false)
		 ; We could check if KN1 is attacked too, but this isn't
		 ; really necessary since Zillions doesn't allow any moves
		 ; into check
	   e ; KN1
	   (set-attribute never-moved? false)
	   add
	 )
)

(define O-O-O
     ( (verify never-moved?)
	   mark
       w ; Q1
       (verify empty?)
       w ; QB1
       (verify empty?)
       cascade
       w ; QN1
       (verify empty?)
       w ; QR1
       (verify (and friend? (piece? Rook) never-moved?) )
       from
       back ; K1
         ; Save expensive not-attacked?s for last
       (verify not-attacked?)
       w ; Q1
       (verify not-attacked?)
       to
       (set-attribute never-moved? false)
         ; We could check if KN1 is attacked too, but this isn't
         ; really necessary since Zillions doesn't allow any moves
         ; into check
       w ; QB1
       (set-attribute never-moved? false)
       add
     )
)

(define Pawn-add
   (if (in-zone? promotion-zone) (add Knight Bishop Rook Queen) else add)
)
(define Pawn-move
   (
      $1
      (verify empty?)
      (Pawn-add)
      (verify (in-zone? third-rank))
      $1
      (verify empty?)
      add
   )
)
(define Pawn-capture ($1 (capturable) (Pawn-add)))
(define En-Passant
   (
      $1
      (verify enemy?)
      (verify last-to?)
      (verify (piece? Pawn))
      capture
      n
      to
      n
      (verify last-from?)
      add
   )
)

(define Weak-Pawn-move-1 (n (verify empty?) add) )
(define Weak-Pawn-move
   (
      n
      (verify empty?)
      add
      (verify (in-zone? third-rank))
      n
      (verify empty?)
      add
   )
)
(define Weak-Pawn-capture ($1 (capturable) add))

(game
   (title "Fairy Chess")
   (description "Fairy Chess\\不要以为你点错了。虽然这个东西看起来像国象，但是你右键点击棋盘空格试试看。没错，右键菜单中包含了几乎所有了仙灵棋集合中的棋子。这是一个可以给你设计棋子作参考的游戏。\
关于这些棋子，你可以百度“Fairy Chess Piece”。\\
这个版本为了上维基方便，我没有翻译棋子名称。\\
      下面是这些棋子的原文，翻译以及简略走法。\\
	Alfil-斜2: 斜跳2格 / Alfilrider: 斜向连续隔一格跳\
	Berolina Pawn-拜罗琳娜兵: 斜走直吃/ Camel-骆驼: 走(1 3)斜角，即跳目字/Camelrider: 连续跳目 \
	Dabbaba-直二: 直跳2格 / Dabbabarider: 连续间隔一个格跳/ Dragon-龙: 兵+马\
	Empress(Marshall)-女皇(元帅): 车+马\
	Fers-斜1: 斜走1格/ Giraffe-长颈鹿: 走(1 4)斜角 / Grasshopper: 必须跳跃走棋\
	Gnu: 日目均可/ Gryphon: 兵+象\
	KnightRider(Nightrider)-蒙面夜骑: 同方向连续跳日/ Lion:八方包，必须隔子走或吃/ Locust: 跳吃\
	Maharaja(Amazon)-亚马逊:后+马 / Mao:中象马\
	Princess(Cardinal)-公主: B+N /Squirrel-松鼠:可以跳到距离自己两步的所有格子\
	Weak Pawn:不升变的兵/ Wazir:直1格/Zebra-斑马:跳用字")
   (history "Experimentation with new types of pieces is as old as the
      game itself.  In fact, modern Chess is the product of such experiments.  It
      wasn't until the end of the 15th century that the Queen and Bishop were
      granted the powerful roles they play today.  You will find their former selves
      in the `Fers` and `Alfil`.  In the early 1900's fairy pieces such as Dawson's
      `Grasshopper` and `Nightrider` were frequently used in problem compositions.
      All of these fairy pieces and more can be found in Anthony Dickins' `A Guide
      to Fairy Chess`.")
   (strategy "You will find that all the basic principles of Chess still apply:
      maximize the activity of your pieces, gain space, and keep your King safe!")
   (option "prevent flipping" 2)
   (win-sound "Audio\\Orchestra_CF.wav")
   (loss-sound "Audio\\Orchestra_FC.wav")
   (click-sound "Audio\\Pickup.wav")
   (release-sound "Audio\\WoodThunk.wav")
   (players White Black Neutral)
   (turn-order White Black)

   (board
      (image "images\Chess\SHaag\Chess8x8.bmp")
      (grid
         (start-rectangle 5 5 53 53)
         (dimensions
             ("a/b/c/d/e/f/g/h" (49 0)) ; files
             ("8/7/6/5/4/3/2/1" (0 49)) ; ranks
         )
         (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			         (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
         )
      )
      (symmetry Black (n s)(s n) (nw sw)(sw nw) (ne se)(se ne))
	  (zone
		 (name promotion-zone)
		 (players White)
		 (positions a8 b8 c8 d8 e8 f8 g8 h8)
	  )
	  (zone
		 (name promotion-zone)
		 (players Black)
		 (positions a1 b1 c1 d1 e1 f1 g1 h1)
	  )
	  (zone
		 (name third-rank)
		 (players White)
		 (positions a3 b3 c3 d3 e3 f3 g3 h3)
	  )
	  (zone
		 (name third-rank)
		 (players Black)
		 (positions a6 b6 c6 d6 e6 f6 g6 h6)
	  )
   )

   (board-setup
      (White
         (Pawn a2 b2 c2 d2 e2 f2 g2 h2)
         (Knight b1 g1)
         (Bishop c1 f1)
         (Rook a1 h1)
         (Queen d1)
         (King e1)
      )
      (Black        
         (Pawn a7 b7 c7 d7 e7 f7 g7 h7)
         (Knight b8 g8)
         (Bishop c8 f8)
         (Rook a8 h8)
         (Queen d8)
         (King e8)
      )
   )

   (piece
      (name Pawn)
      (help "兵：开始时向前进1-2格，向前移动1格，只能斜进1格吃子。可以在对方底线升变。")
      (description "兵\在初始位置时，可以向前进1-2格，以后只能向前1格。兵吃子只能斜进1格吃。\若兵到达对方底线，必须升变为车马象后中的任意一个。\当对方兵挺进两格而与你的兵并列时，你可以斜进一格吃掉它。")
      (image White "images\Chess\SHaag\wpawn.bmp" Black "images\Chess\SHaag\bpawn.bmp")
      (moves
         (Pawn-capture nw)
         (Pawn-capture ne)
         (Pawn-move n)
      )
   )
   (piece
      (name Knight)
      (help "马：跳日字，可越子，不蹩腿。")
      (description "马\马走类似“日”字，即从一个1x2的长方形一角走到对角，或先直移一步，然后再往那个方向斜移一步。马是国际象棋唯一一个可以越子移动的棋子。")
      (image White "images\Chess\SHaag\wknight.bmp" Black "images\Chess\SHaag\bknight.bmp")
      (moves (Knight-moves))
   )
   (piece
      (name Bishop)
      (help "象：走斜线，格数不限")
      (description "象\象走斜线，格数不限，不能越子。")
      (image White "images\Chess\SHaag\wbishop.bmp" Black "images\Chess\SHaag\bbishop.bmp")
      (moves (Bishop-moves))
   )
   (piece
      (name Rook)
      (help "车：直走，格数不限。")
      (description "车\车走横直均可，格数不限。不能越子。")
      (image White "images\Chess\SHaag\wrook.bmp" Black "images\Chess\SHaag\brook.bmp")
      (attribute never-moved? true)
      (moves
         (Rook-ride n)
         (Rook-ride e)
         (Rook-ride s)
         (Rook-ride w)
      )
   )
   (piece
      (name Queen)
      (help "后：八方向走，格数不限。")
      (description "后\后是国际象棋里威力最强大的棋子，它可以走横直斜八个方向，且不限格数。")
      (image White "images\Chess\SHaag\wqueen.bmp" Black "images\Chess\SHaag\bqueen.bmp")
      (moves (Bishop-moves) (Rook-moves))
   )
   (piece
      (name King)
      (help "王：横直斜走1格，被将死输。")
      (description "王\王走八方1格，但是任何时候都不能被吃。\王有王车易位的移动方式，即王可以向车方向移动两格，然后车越过王与王相邻。以下场合不可易位：\①王被将军；\②王或者车已经动过；\③王车之间的格子有棋子，或者空格可被对方攻击。")
      (image White "images\Chess\SHaag\wking.bmp" Black "images\Chess\SHaag\bking.bmp")
      (attribute never-moved? true)
      (moves
         (King-shift n)
         (King-shift e)
         (King-shift s)
         (King-shift w)
         (King-shift ne)
         (King-shift nw)
         (King-shift se)
         (King-shift sw)
         (O-O)
         (O-O-O)
      )
   )

   ; *** Fairy pieces
   (piece
      (name Block)
      (help "墙：阻挡所有棋子通过")
      (description "墙\阻挡所有棋子通过。")
      (image Neutral "images\Chess\Block.bmp")
   )
   (piece
      (name Weak-Pawn)
      (help "不升变的兵：开始时向前进1-2格，向前移动1格，只能斜进1格吃子。不可升变")
      (description "兵\在初始位置时，可以向前进1-2格，以后只能向前1格。兵吃子只能斜进1格吃。\当对方兵挺进两格而与你的兵并列时，你可以斜进一格吃掉它。\此兵不可升变。")
      (image White "images\Fairy_Chess\WPawn-weak.bmp" Black "images\Fairy_Chess\BPawn-weak.bmp")
      (moves
         (Weak-Pawn-capture nw)
         (Weak-Pawn-capture ne)
         (Weak-Pawn-move)
      )
   )
   (piece
      (name Berolina-Pawn)
      (help "拜罗琳娜兵：开始时斜前进1-2格，此后斜前移动1格，只能前进1格吃子。")
      (description "拜罗琳娜兵\刚好和国际象棋兵相反。它在初始位置可以斜向前走2格，以后只能斜前移动1格。它只能前进1格吃子。")
      (image White "images\Fairy_Chess\WPawn-ber.bmp" Black "images\Fairy_Chess\BPawn-ber.bmp")
      (moves
         (Pawn-capture n)
         (Pawn-move ne)
         (Pawn-move nw)
      )
   )
   (piece
      (name Grasshopper)
      (help "跳跃者：必须跳过一个棋子行动。")
      (description "跳跃者(Grasshopper)\跳跃者八个方向均可走，但必须跳过一个棋子然后落在它后面。若后面那格有敌方棋子，可以吃掉。")
      (image White "images\Chess\SHaag\WDownQueen.bmp" Black "images\Chess\SHaag\BDownQueen.bmp")
      (moves
         (grasshop n)
         (grasshop e)
         (grasshop s)
         (grasshop w)
         (grasshop ne)
         (grasshop nw)
         (grasshop se)
         (grasshop sw)
	   )
   )
   (piece
      (name Locust)
      (help "跳杀者：跳过对方的棋子吃，然后落在它后面一格。")
      (description "跳杀者(Locust)\跳杀者八方均可移动，但必须越过一个敌方棋子，杀死它，然后到达它后面的空格。跳杀者不吃子时不能移动。")
      (image White "images\Fairy_Chess\WDownQueen-loc.bmp" Black "images\Fairy_Chess\BDownQueen-loc.bmp")
      (moves
         (Locust-move n)
         (Locust-move e)
         (Locust-move s)
         (Locust-move w)
         (Locust-move ne)
         (Locust-move nw)
         (Locust-move se)
         (Locust-move sw)
	   )
   )
   (piece
      (name Lion)
      (help "飞跃者：跳过一个棋子移动，落在它后面然后可以继续走")
      (description "飞跃者(Lion)\飞跃者必须隔一个棋子走或吃子。\\与该棋子相同的：韩国象棋的包（炮）。")
      (image White "images\Fairy_Chess\WDownQueen-lion.bmp" Black "images\Fairy_Chess\BDownQueen-lion.bmp")
      (moves
         (Lion-move n)
         (Lion-move e)
         (Lion-move s)
         (Lion-move w)
         (Lion-move ne)
         (Lion-move nw)
         (Lion-move se)
         (Lion-move sw)
      )
   )
   (piece
      (name Nightrider)
      (help "蒙面夜骑：同方向连续跳日")
      (description "蒙面夜骑(Nightrider)\同方向连续跳日字。不能踩在其他棋子头上继续跳。")
      (image White "images\Chess\SHaag\WDownKnight.bmp" Black "images\Chess\SHaag\BDownKnight.bmp")
      (moves
	     (leap2ride n ne)
	     (leap2ride n nw)
	     (leap2ride s se)
	     (leap2ride s sw)
	     (leap2ride e ne)
	     (leap2ride e se)
	     (leap2ride w nw)
	     (leap2ride w sw)
      )
   )
   (piece
      (name Wazir)
      (help "Wazir:直走一格。")
      (description "Wazir\只能横或纵走一格。\\与该棋子移动一样的有：中象的将，将棋系列的嗔猪。")
      (image White "images\Fairy_Chess\WRook-waz.bmp" Black "images\Fairy_Chess\BRook-waz.bmp")
      (moves (Wazir-moves))
   )
   (piece
      (name Fers)
      (help "Fers:斜走一格。")
      (description "Fers/Ferz\斜走一格。\\与该棋子移动相同的：中国象棋、泰国象棋、缅甸象棋的士，将棋系列的猫刃")
      (image White "images\Fairy_Chess\WQueen-fers.bmp" Black "images\Fairy_Chess\BQueen-fers.bmp")
      (moves (Fers-moves))
   )
   (piece
      (name Mao)
      (help "蹩腿马：跳日，蹩腿")
      (image White "images\Fairy_Chess\WKnight-mao.bmp" Black "images\Fairy_Chess\BKnight-mao.bmp")
      (description "中象马\跳日，但横/竖一格是蹩腿点")
      (moves
	     (shift2 n ne)
	     (shift2 n nw)
	     (shift2 s se)
	     (shift2 s sw)
	     (shift2 e ne)
	     (shift2 e se)
	     (shift2 w nw)
	     (shift2 w sw)
      )
   )
   (piece
      (name Alfil)
      (help "Alfil: 斜跳2格，可越子")
      (description "Alfil\斜跳两格。\\与该棋子类似的：中国象棋的象（塞象眼）。将棋系列的凤凰（+直1）、高道等")
      (image White "images\Fairy_Chess\WBishop-al.bmp" Black "images\Fairy_Chess\BBishop-al.bmp")
      (moves (Alfil-moves))
   )
   (piece
      (name Alfilrider)
      (help "Alfilrider: 斜跳偶数个格")
      (description "Alfilrider\连续以“斜二”的步法跳，即连续的隔一格跳跃。")
      (image White "images\Chess\SHaag\WDownBishop.bmp" Black "images\Chess\SHaag\BDownBishop.bmp")
      (moves
         (leap2ride nw nw)
         (leap2ride ne ne)
         (leap2ride sw sw)
         (leap2ride se se)
      )
   )
   (piece
      (name Dabbaba)
      (help "Dabbaba:直跳2格。")
      (description "Dabbaba\横或竖跳2格。\\与该棋子类似的：将棋的麒麟（+斜1）、高道等")
      (image White "images\Fairy_Chess\WRook-dab.bmp" Black "images\Fairy_Chess\BRook-dab.bmp")
      (moves (Dabbaba-moves))
   )
   (piece
      (name Dabbabarider)
      (help "Dabbabarider: 直跳偶数个格")
      (description "Dabbabarider\连续以“直二”的步法跳，即连续的隔一格跳跃。")
      (image White "images\Chess\SHaag\WDownRook.bmp" Black "images\Chess\SHaag\BDownRook.bmp")
      (moves
         (leap2ride n n)
         (leap2ride e e)
         (leap2ride w w)
         (leap2ride s s)
      )
   )
   (piece
      (name Camel)
      (help "Camel: 跳目字")
      (description "Camel\跳目字，即横1步竖3步，或横3步竖1步。可越子。")
      (image White "images\Fairy_Chess\WKnight-cam.bmp" Black "images\Fairy_Chess\BKnight-cam.bmp")
      (moves (Camel-moves))
   )
   (piece
      (name Camelrider)
      (help "Camelrider: 连续跳目")
      (description "Camelrider\同方向连续跳目字。不得踩棋子头上继续跳。")
      (image White "images\Fairy_Chess\WDownKnight-cr.bmp" Black "images\Fairy_Chess\BDownKnight-cr.bmp")
      (moves
	     (leap3ride n n ne)
	     (leap3ride n n nw)
	     (leap3ride s s se)
	     (leap3ride s s sw)
	     (leap3ride e e ne)
	     (leap3ride e e se)
	     (leap3ride w w nw)
	     (leap3ride w w sw)
      )
   )
   (piece
      (name Giraffe)
      (help "Giraffe:走(1 4)斜角")
      (description "Giraffe\实在是没有汉字可以形容这个走法。它可以横1步竖4步，或横4步竖1步。可越子。")
      (image White "images\Fairy_Chess\WKnight-gir.bmp" Black "images\Fairy_Chess\BKnight-gir.bmp")
      (moves
	     (leap4 n n n ne)
	     (leap4 n n n nw)
	     (leap4 s s s se)
	     (leap4 s s s sw)
	     (leap4 e e e ne)
	     (leap4 e e e se)
	     (leap4 w w w nw)
	     (leap4 w w w sw)
      )
   )
   (piece
      (name Zebra)
      (help "Zebra: 跳用字")
      (description "Zebra\跳用字，即横2步竖3步，或横3步竖2步。\\与该棋子类似的：韩国象棋的象（蹩腿+塞眼）。日+目+用+八方无限即可覆盖7x7的区域，在大型棋盘中很常见。")
      (image White "images\Fairy_Chess\WKnight-zeb.bmp" Black "images\Fairy_Chess\BKnight-zeb.bmp")
      (moves
	     (leap3 n ne ne)
	     (leap3 n nw nw)
	     (leap3 s se se)
	     (leap3 s sw sw)
	     (leap3 e ne ne)
	     (leap3 e se se)
	     (leap3 w nw nw)
	     (leap3 w sw sw)
      )
   )

   ;*** Combination pieces
   (piece
      (name Princess)
      (help "公主：象+马")
      (description "Princess (Cardinal)\它可以按象的步法移动，也可以按马的步法移动。即：斜走不限，或跳日")
      (image White "images\Chess\SHaag\WKnightBishop.bmp" Black "images\Chess\SHaag\BKnightBishop.bmp")
      (moves (Bishop-moves) (Knight-moves))
   )
   (piece
      (name Empress)
      (help "女皇：车+马")
      (description "Empress (Marshall, Chancellor)\它可以按车的步法移动，也可以按马的步法移动。即：直走不限，或跳日")
      (image White "images\Chess\SHaag\WKnightRook.bmp" Black "images\Chess\SHaag\BKnightRook.bmp")
      (moves (Rook-moves) (Knight-moves))
   )
   (piece
      (name Gnu)
      (help "Gnu: 日+目")
      (description "Gnu (Wildebeest)\它可以跳日字或目字。")
      (image White "images\Fairy_Chess\WKnight-gnu.bmp" Black "images\Fairy_Chess\BKnight-gnu.bmp")
      (moves (Camel-moves) (Knight-moves))
   )
   (piece
      (name Squirrel)
      (help "松鼠：八方向跳2格+马步")
      (description "Squirrel\它可以跳到距离自己2格的一圈范围。即跳日，或者八方向跳2格。")
      (image White "images\Fairy_Chess\WKnight-sq.bmp" Black "images\Fairy_Chess\BKnight-sq.bmp")
      (moves (Alfil-moves) (Dabbaba-moves) (Knight-moves))
   )
   (piece
      (name Dragon)
       (help "Dragon: 兵+马")
     (description "Dragon\按兵的步法移动，或按马的步法移动。没有升变、挺兵、吃过路兵。即：除了跳日之外，还可以向前一步走，或斜前一步吃。")
      (image White "images\Fairy_Chess\WKnight-dr.bmp" Black "images\Fairy_Chess\BKnight-dr.bmp")
      (moves (Weak-Pawn-move-1) (Weak-Pawn-capture ne) (Weak-Pawn-capture nw) (Knight-moves))
   )
   (piece
      (name Gryphon)
      (help "Gryphon: 象+兵")
      (description "Gryphon (Griffin)\按兵的步法移动，或按象的步法移动。没有升变、挺兵、吃过路兵。即：除了斜走之外，还可以向前一步走。")
      (image White "images\Fairy_Chess\WBishop-gr.bmp" Black "images\Fairy_Chess\BBishop-gr.bmp")
      (moves (Weak-Pawn-move-1) (Weak-Pawn-capture ne) (Weak-Pawn-capture nw) (Bishop-moves))
   )
   (piece
      (name Maharaja)
      (help "亚马逊: 后+马")
      (image White "images\Chess\SHaag\WDownQueen.bmp" Black "images\Chess\SHaag\Maharaja.bmp")
      (description "Maharaja (Amazon)\亚马逊：威力非常强大，它可以按后的步法或马的步法移动。\也就是说，它八方走，格数不限，还可以跳日。\\换句话说，它可以覆盖自身周围5x5的区域。")
      (moves (Rook-moves) (Bishop-moves) (Knight-moves))
   )

   (loss-condition (White Black) (checkmated King) )
)

; **************************************************************************
; ### Other rules:
;      Alfils may not attack each other
;      Ferses may not attack each other (unless one is a promoted pawn)?
;      Okay to lose all your pieces if you can capture your opponent's last piece next move
(define Shatranj-Pawn-add (if (in-zone? promotion-zone) (add Fers) else add))
(define Shatranj-Pawn-move (n (verify empty?) (Shatranj-Pawn-add)))
(define Shatranj-Pawn-capture ($1 (capturable) (Shatranj-Pawn-add)))
(variant
   (title "Shatranj")
   (description "与国际象棋类似。但后只能斜走一格，象只能斜跳2格，兵只能走1格，只能升变为后。\\另外有孤王负规则，即对方只剩一个王时也算输。")
   (history "Shatranj is the Arabic name for Chess.  In this early form it was
      played for a millennium in Muslem countries.  For a detailed history
	  see Murray's `A History of Chess.`")
   (strategy "Shatranj is like a Chess endgame.  The Shah plays a powerful
      offensive role.")
   (piece
      (name Shah)
	  (help "王(Shah)：八方一格，被将死输，无易位")
      (description "王(Shah)\王可以向横、竖或斜走一格，被将死输，无易位")
      (image White "images\Chess\SHaag\wking.bmp" Black "images\Chess\SHaag\bking.bmp")
      (moves (Wazir-moves) (Fers-moves))
   )
   (piece
      (name Pawn)
      (image White "images\Chess\SHaag\wpawn.bmp" Black "images\Chess\SHaag\bpawn.bmp")
	  (description "兵(Foot Soldier)\只能向前移动一格，吃法不变。只能升变为后。")
	  (help "兵：直走斜吃，只能升变为后")
      (moves
         (Shatranj-Pawn-capture nw)
         (Shatranj-Pawn-capture ne)
         (Shatranj-Pawn-move)
      )
   )
   (board-setup
      (White
         (Pawn a2 b2 c2 d2 e2 f2 g2 h2)
         (Knight b1 g1)
         (Alfil c1 f1)
         (Rook a1 h1)
         (Fers e1)
         (Shah d1)
      )
      (Black        
         (Pawn a7 b7 c7 d7 e7 f7 g7 h7)
         (Knight b8 g8)
         (Alfil c8 f8)
         (Rook a8 h8)
         (Fers e8)
         (Shah d8)
      )
   )
   (loss-condition (White Black) (checkmated Shah) )
   (loss-condition (White Black) stalemated )
   (loss-condition (White Black) (pieces-remaining 1) ) ; bare king
)

; **************************************************************************
(variant
   (title "Maharaja and the Sepoys")
   (description "亚马逊单挑战\\
	白方使用国际象棋全部棋子，目标是将死对方亚马逊；黑方使用一个亚马逊，目标是将死对方王。\
	亚马逊的走法是后+马。
\\此玩法白方兵不升变。")
   (history "This game comes from mid-19th century India.")
   (strategy "The White side should note that as long as he keeps all of
      his pieces protected, the Maharaja can never afford to make any captures.  To
	  win, White should concentrate on covering all the squares to push the
	  Maharaja back rank by rank, allowing him no safe escape.  The Maharaja
	  should look for ways to harrass White and opportunities to invade with
	  checkmate.\\If White is careful he can force a win, but it is very easy
	  to make a mistake and let the powerful Maharaja in.  A good player should
	  be able to trap the Maharaja in 20 moves.")
   (board-setup
      (White
         (Weak-Pawn a2 b2 c2 d2 e2 f2 g2 h2)
         (Knight b1 g1)
         (Bishop c1 f1)
         (Rook a1 h1)
         (Queen d1)
         (King e1)
      )
      (Black        
         (Maharaja e8)
      )
   )
   (loss-condition (White) (checkmated King) )
   (loss-condition (Black) (checkmated Maharaja) )
)

; **************************************************************************
(variant
   (title "Berolina Chess")
   (description "拜罗琳娜兵\\这个玩法所有的兵都为拜罗琳娜兵。\\拜罗琳娜兵：初始位置可以斜前走2格，之后只能斜前1格。只能直前1格吃。")
   (history "The Berolina Pawn was invented by Edmund Hebermann of Berlin in
      1926 and since then has been popular with puzzle composers.  Even the
	  great Chess-player Dr. Emmanuel Lasker has studied the Pawn's
	  properties.  Berolina Chess tournaments have been held, and it is
	  still a popular postal game in NOST and AISE.")
   (strategy "Berolina Pawns are more mobile than normal Pawns and can
      easily reach the center of the board and congregate there.  The
	  only supported Pawn chain they can form is along a file, so positions
	  are less likely to become blocked than in Chess.  Since Berolina Pawns
	  are not as tied down to their files, files are quickly opened up for
	  Rooks and Queens.")
   (board-setup
      (White
         (Berolina-Pawn a2 b2 c2 d2 e2 f2 g2 h2)
         (Knight b1 g1)
         (Bishop c1 f1)
         (Rook a1 h1)
         (Queen d1)
         (King e1)
      )
      (Black        
         (Berolina-Pawn a7 b7 c7 d7 e7 f7 g7 h7)
         (Knight b8 g8)
         (Bishop c8 f8)
         (Rook a8 h8)
         (Queen d8)
         (King e8)
      )
   )
   (loss-condition (White Black) (checkmated King) )
)

; **************************************************************************
(variant
   (title "No High Ground")
   (description "这个玩法里面中心4格是墙。")
   (history "Invented by Mark Lefler.");  
   (board-setup
      (White
         (Pawn a2 b2 c2 d2 e2 f2 g2 h2)
         (Knight b1 g1)
         (Bishop c1 f1)
         (Rook a1 h1)
         (Queen d1)
         (King e1)
      )
      (Black
         (Pawn a7 b7 c7 d7 e7 f7 g7 h7)
         (Knight b8 g8)
         (Bishop c8 f8)
         (Rook a8 h8)
         (Queen d8)
         (King e8)
      )
      (Neutral
         (Block e4 e5 d4 d5)
      )
   )
)

; **************************************************************************
(define G-Pawn-add
   (if (in-zone? promotion-zone) (add Knight Bishop Rook Queen Grasshopper) else add)
)
(define G-Pawn-move (n (verify empty?) (G-Pawn-add)) )
(define G-Pawn-capture ($1 (capturable) (G-Pawn-add)) )

(variant
   (title "Grasshopper Chess")
   (description "此玩法增加了一排跳跃者。跳跃者必须跳过一个子移动或吃子，且只能落到被跳的棋子后方一格。")
   (history "Invented by Joseph Boyer, based on the piece Dawson invented in 1912.")
   (strategy "Hint: The value of a Grasshopper decreases throughout the game due
      to the fact that there are fewer and fewer pieces to jump over.")
   (piece
      (name Pawn)
      (help "兵：无法前进2格。")
      (description "兵\直进1格，斜吃1格。可升变。")
      (image White "images\Chess\SHaag\wpawn.bmp" Black "images\Chess\SHaag\bpawn.bmp")
      (moves
         (G-Pawn-capture nw)
         (G-Pawn-capture ne)
         (G-Pawn-move)
      )
   )
   (board-setup
      (White
         (Pawn a3 b3 c3 d3 e3 f3 g3 h3)
         (Grasshopper a2 b2 c2 d2 e2 f2 g2 h2)
         (Knight b1 g1)
         (Bishop c1 f1)
         (Rook a1 h1)
         (Queen d1)
         (King e1)
      )
      (Black
         (Pawn a6 b6 c6 d6 e6 f6 g6 h6)
         (Grasshopper a7 b7 c7 d7 e7 f7 g7 h7)
         (Knight b8 g8)
         (Bishop c8 f8)
         (Rook a8 h8)
         (Queen d8)
         (King e8)
      )
   )
 )

; **************************************************************************
(define zoom (
	$1
	(verify not-friend?)
	(if (piece? King) (verify not-attacked?))
	(set-attribute never-moved? false) add
))
(variant
   (title "Emperor King Chess")
   (description "此玩法里，你的王变为自在天王，可以飞到棋盘上任意一个地点，也可以吃掉任何无其他棋子保护的敌方棋子。\\换句话说，如果你的王没有其他棋子保护，对方的王可以直接把你吃掉。所以，你的自在天王必须时刻处于自己其他棋子的保护范围内。")
   (history "The Emperor piece comes from Tai Shogi, a 25x25 medieval variant of Shogi.
      R. Wayne Schmittberger, in his book `New Rules for Classic Games`, adapted it to
      Chess.")
   (strategy "Sacrificing to disrupt the protection around the Emperor may not be
      as good a strategy as in Chess, as the Emperor can fly to the other side of
      the board in a single move.  Keep in mind that the Emperor is not good at defending
      pieces, since it can't move to an unprotected square.")
   (piece
      (name King)
      (help "自在天王：全盘移动，自由越子。")
      (description "自在天王\自在天王可以全盘任意移动，且可以自由越子。自在天王还可以吃掉无保护的敌方棋子。自在天王也有王车易位。被将死输。")
      (image White "images\Chess\SHaag\wking.bmp" Black "images\Chess\SHaag\bking.bmp")
      (attribute never-moved? true)
      (moves
         (zoom a8)(zoom b8)(zoom c8)(zoom d8)(zoom e8)(zoom f8)(zoom g8)(zoom h8)
         (zoom a7)(zoom b7)(zoom c7)(zoom d7)(zoom e7)(zoom f7)(zoom g7)(zoom h7)
         (zoom a6)(zoom b6)(zoom c6)(zoom d6)(zoom e6)(zoom f6)(zoom g6)(zoom h6)
         (zoom a5)(zoom b5)(zoom c5)(zoom d5)(zoom e5)(zoom f5)(zoom g5)(zoom h5)
         (zoom a4)(zoom b4)(zoom c4)(zoom d4)(zoom e4)(zoom f4)(zoom g4)(zoom h4)
         (zoom a3)(zoom b3)(zoom c3)(zoom d3)(zoom e3)(zoom f3)(zoom g3)(zoom h3)
         (zoom a2)(zoom b2)(zoom c2)(zoom d2)(zoom e2)(zoom f2)(zoom g2)(zoom h2)
         (zoom a1)(zoom b1)(zoom c1)(zoom d1)(zoom e1)(zoom f1)(zoom g1)(zoom h1)
         (O-O)
         (O-O-O)
      )
   )
)

; **************************************************************************
(variant
   (title "Stationary King Chess")
   (description "此玩法下，国王不可移动。")
   (history "Many different variations of Chess have been invented that involve
      immobilized pieces or limit the way a King may evade check.  This particular
      variant has been re-invented multiple times.")
   (strategy "Keep in mind that the f2 and f7 squares are even more vulnerable
      than in normal Chess.  Also remember that there is no castling, as the
      King is stuck in the center.")
   (piece
      (name King)
      (help "懒蛋国王：不移动。")
      (description "王\此规则下，王不移动。被将死输。当然也没有王车易位。")
      (image White "images\Chess\SHaag\WKing.bmp" Black "images\Chess\SHaag\BKing.bmp")
   )
)

; **************************************************************************

(define Board-Definitions-10x10
  (image "images\Chess\SHaag\Chess10x10.bmp")
  (grid
         (start-rectangle 5 5 53 53)
         (dimensions
             ("a/b/c/d/e/f/g/h/i/j" (49 0)) ; files
             ("10/9/8/7/6/5/4/3/2/1" (0 49)) ; ranks
         )
         (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			         (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
         )
  )
  (symmetry Black (n s)(s n) (nw sw)(sw nw) (ne se)(se ne))
  (zone
     (name final-rank)
     (players White)
     (positions a10 b10 c10 d10 e10 f10 g10 h10 i10 j10)
  )
  (zone
     (name final-rank)
     (players Black)
     (positions a1 b1 c1 d1 e1 f1 g1 h1 i1 j1)
  )
  (zone
     (name promotion-zone)
     (players White)
     (positions a8 b8 c8 d8 e8 f8 g8 h8 i8 j8 a9 b9 c9 d9 e9 f9 g9 h9 i9 j9)
  )
  (zone
     (name promotion-zone)
     (players Black)
     (positions a3 b3 c3 d3 e3 f3 g3 h3 i3 j3 a2 b2 c2 d2 e2 f2 g2 h2 i2 j2)
  )
  (zone
     (name third-rank)
     (players White)
     (positions a4 b4 c4 d4 e4 f4 g4 h4 i4 j4)
  )
  (zone
     (name third-rank)
     (players Black)
     (positions a7 b7 c7 d7 e7 f7 g7 h7 i7 j7)
  )
)

(define GC-Pawn-add
   (if (in-zone? promotion-zone) (add Knight Bishop Rook Queen Empress Princess))
   (if (and (in-zone? final-rank)(piece? King)) add)
   (if (in-zone? final-rank) (add Knight Bishop Rook Queen Empress Princess) else add)
)
(define GC-Pawn-move
   (
      n
      (verify empty?)
      (GC-Pawn-add)
      (verify (in-zone? third-rank))
      n
      (verify empty?)
      add
   )
)
(define GC-Pawn-capture
   (
      $1
      (verify enemy?)
      (GC-Pawn-add)
   )
)

(variant
   (title "Grand Chess")
   (description "这是一个10x10的大型象棋变体，新增了两个棋子：女皇（车+马）、公主（象+马）。\\没有王车易位。\\兵升变区域在对方阵线3行，即从本阵数第8-10行。\兵走到第8或第9行时，可以选择不升变，但到对方底线时强制升变，且只能升变成被吃的棋子。\\在己方没有其他棋子死亡的场合，兵不可到达对方底线。")
   (history "Grand Chess was constructed by Dutch games designer Christian Freeling. It is in many ways an improved version of Capablanca's large chess.")
   (strategy "Most things that are valid in ordinary chess also goes for Grand Chess.")
   (option "recycle captures" true)
   (option "recycle promotions" true)
   (board (Board-Definitions-10x10))

   (board-setup
      (White
         (Pawn a3 b3 c3 d3 e3 f3 g3 h3 i3 j3)
         (Knight b2 i2)
         (Bishop c2 h2)
         (Rook a1 j1)
         (Empress f2)
         (Princess g2)
         (Queen d2)
         (King e2)
      )
      (Black
         (Pawn a8 b8 c8 d8 e8 f8 g8 h8 i8 j8)
         (Knight b9 i9)
         (Bishop c9 h9)
         (Rook a10 j10)
         (Empress f9)
         (Princess g9)
         (Queen d9)
         (King e9)
      )
   )

   (piece
      (name Pawn)
	(help "兵：开始时向前进1-2格，向前移动1格，只能斜进1格吃子。可以在对方阵线内升变。")
      (description "兵\在初始位置时，可以向前进1-2格，以后只能向前1格。兵吃子只能斜进1格吃。\当对方兵挺进两格而与你的兵并列时，你可以斜进一格吃掉它。\若兵到达第8行或第9行，可以升变为被吃棋子中的任意一个，但到达对方底线必须升变。在己方没有其他棋子死亡的场合，兵不可到达对方底线，但依然可以将军处于底线的王。")
      (description "Pawn\A Pawn can move straight ahead one square, or two 
squares from its starting position.  A Pawn captures by moving one square ahead and 
diagonally. On rare occasions Pawns can also execute a move called `En Passant`, 
or `in passing`. This allows a Pawn to take an enemy Pawn that has just moved two 
squares.\Upon reaching eighth rank, Pawns promote to any captured piece. 
Promotion is not mandatory and is also possible on ninth and tenth rank. However, 
the Pawn can not move to tenth rank if there are no pieces to promote to, although 
it can still give check from the ninth rank.")
     (image White "images\Chess\SHaag\WPawn.bmp" Black "images\Chess\SHaag\BPawn.bmp")
     (moves
         (GC-Pawn-capture nw)
         (GC-Pawn-capture ne)
         (GC-Pawn-move)
         (En-Passant e)
         (En-Passant w)
      )
   )
)
